var t = require("../../../@babel/runtime/helpers/interopRequireDefault"), a = require("../../../@babel/runtime/helpers/defineProperty"), e = t(require("../../../@babel/runtime/regenerator")), i = require("../../../@babel/runtime/helpers/asyncToGenerator"), s = getApp();

Page({
    data: {
        explainFlag: !1,
        agreement: !1,
        agreementText: "",
        startDate: new Date("1900-01-01"),
        msgText: 0,
        pass_safe: 0,
        showtips: !0,
        supplier_status: -2,
        showAddress: !1,
        supplier_info: "",
        isDiyForm: 0,
        form_id: "",
        types: {
            88: "diyusername",
            99: "diypassword",
            0: "diyinput",
            1: "diytextarea",
            3: "diycheckbox",
            4: "diyradio",
            2: "diyselect",
            7: "diydate",
            9: "diycity",
            5: "diyimage"
        },
        diydata: [],
        applyModel: {
            username: "",
            password: "",
            realname: "",
            mobile: "",
            product: "",
            remark: "",
            province_name: "",
            city_name: "",
            district_name: "",
            street_name: "",
            group_id: "",
            category_id: "",
            aptitude: [],
            identity: []
        },
        setname: "",
        uploadUrl: "upload.uploadPic",
        provinceData: [],
        cityData: [],
        districtData: [],
        pickerValue: [ 0, 0, 0 ],
        selectAddressData: [],
        currentDate: new Date().getTime(),
        showCity1: !1,
        isValidation: !0,
        select: !1,
        grouping_name: "请选择分组",
        grouping: [],
        up_aptitude: "",
        is_identity: "",
        group_list: [],
        select_ind: !1,
        industry_name: "请选择行业",
        industry: [],
        is_open_category: "",
        is_open_group: "",
        isShowStreet: !1,
        districtVal: [],
        streetShow: !1,
        imagefile1: "",
        imagefile2: "",
        apply_page_banner: "",
        apply_switch: !1
    },
    onLoad: function(t) {
        var a, e;
        this._initAddressInfo(), this._getData(), this.getApply();
        var i = wx.getStorageSync("yz_basic_info");
        this.setData({
            apply_switch: null !== (a = null === (e = i.plugin_setting.sub_platform) || void 0 === e ? void 0 : e.apply_switch) && void 0 !== a && a
        });
    },
    bindGrouping: function() {
        this.setData({
            select: !this.data.select
        });
    },
    selectGrouping: function(t) {
        console.log(t);
        var a = t.currentTarget.dataset.datalist.title;
        this.data.applyModel.group_id = t.currentTarget.dataset.datalist.id, this.setData({
            group_list: t.currentTarget.dataset.datalist,
            grouping_name: a,
            select: !1,
            "applyModel.aptitude": [],
            up_aptitude: t.currentTarget.dataset.datalist.up_aptitude,
            is_identity: t.currentTarget.dataset.datalist.is_identity
        });
    },
    bindIndustry: function() {
        this.setData({
            select_ind: !this.data.select_ind
        });
    },
    selectIndustry: function(t) {
        console.log(t);
        var a = t.currentTarget.dataset.datalist.title;
        this.data.applyModel.category_id = t.currentTarget.dataset.datalist.id, this.setData({
            industry_name: a,
            select_ind: !1
        });
    },
    del: function(t) {
        var a = parseInt(t.target.dataset.index), e = this.data.applyModel.aptitude;
        e.splice(a, 1), this.setData({
            "applyModel.aptitude": e
        });
    },
    bindUpImage: function() {
        var t = this;
        return i(e.default.mark(function a() {
            var i, s, n, o;
            return e.default.wrap(function(a) {
                for (;;) switch (a.prev = a.next) {
                  case 0:
                    return a.next = 2, t.selectImage();

                  case 2:
                    i = a.sent, console.log(i, "sssss"), s = t.data.applyModel.aptitude, n = 0;

                  case 6:
                    if (!(n < i.length)) {
                        a.next = 16;
                        break;
                    }
                    return a.next = 9, t.uploadImage(i[n]);

                  case 9:
                    o = a.sent, console.log(o, "data"), s.push(o.img_url), t.setData({
                        "applyModel.aptitude": s
                    });

                  case 13:
                    n++, a.next = 6;
                    break;

                  case 16:
                  case "end":
                    return a.stop();
                }
            }, a);
        }))();
    },
    selectImage: function() {
        return new Promise(function(t, a) {
            wx.chooseImage({
                sizeType: [ "original", "compressed" ],
                sourceType: [ "album", "camera" ],
                success: function(a) {
                    t(a.tempFilePaths);
                }
            });
        });
    },
    uploadImage: function(t) {
        return new Promise(function(a, e) {
            wx.showLoading({
                title: "上传图片中"
            });
            var i = s.getNetAddresss("upload.uploadPic");
            wx.uploadFile({
                url: i,
                filePath: t,
                name: "file",
                success: function(t) {
                    var e = JSON.parse(t.data);
                    1 == e.result ? a(e.data) : wx.showToast({
                        icon: "none",
                        title: e.msg,
                        duration: 1500
                    });
                },
                complete: function() {
                    wx.hideLoading();
                }
            });
        });
    },
    getApply: function() {
        var t = this, a = s.getNetAddresss("plugin.supplier.supplier.controllers.apply.supplier-apply.index");
        s._getNetWork({
            url: a,
            data: {
                validate_page: 1
            },
            success: function(a) {
                var e = a.data;
                1 == e.result ? t.setData({
                    grouping: e.data.groups,
                    industry: e.data.categorys,
                    is_open_category: e.data.is_open_category,
                    is_open_group: e.data.is_open_group
                }) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    changeAgreement: function(t) {
        this.setData({
            agreement: t.detail
        });
    },
    setExplainFlag: function() {
        this.setData({
            explainFlag: !this.data.explainFlag
        });
    },
    timestampToTime: function(t) {
        var a = new Date(t);
        return a.getFullYear() + "-" + ((a.getMonth() + 1 < 10 ? "0" + (a.getMonth() + 1) : a.getMonth() + 1) + "-") + (this.change(a.getDate()) + " ");
    },
    change: function(t) {
        return t < 10 ? "0" + t : t;
    },
    birthdayconfirm: function(t, e) {
        var i, s = t.currentTarget.dataset.idex, n = t.detail;
        this.setData((a(i = {}, "diydata[" + s + "].value", String(n).substring(0, 10)), 
        a(i, "shoTime", this.timestampToTime(n)), a(i, "diydata[" + s + "].timeShow", !1), 
        i));
    },
    dateClose: function(t) {
        var e = t.currentTarget.dataset.idex;
        this.setData(a({}, "diydata[" + e + "].timeShow", !1));
    },
    _getData: function() {
        var t = this, a = s.getNetAddresss("plugin.supplier.supplier.controllers.apply.supplier-apply");
        s._getNetWork({
            url: a,
            success: function(a) {
                var e = a.data;
                if (1 == e.result) {
                    if (t.setData({
                        supplier_status: e.data.status,
                        pass_safe: e.data.safe,
                        agreementText: e.data.agreement,
                        apply_page_banner: e.data.apply_page_banner
                    }), 1 == t.data.supplier_status) return "1" == e.data.is_open_region && t.setData({
                        showAddress: !0
                    }), t.checkEnableDiyForm(), void t.setData({
                        supplier_info: e.data.signature
                    });
                } else wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    checkEnableDiyForm: function() {
        var t = this, a = s.getNetAddresss("plugin.supplier.supplier.controllers.apply.supplier-apply.is-enable-diyform");
        s._getNetWork({
            url: a,
            success: function(a) {
                var e = a.data;
                1 == e.result && (t.setData({
                    supplier_status: 2,
                    isDiyForm: 1,
                    form_id: e.data.form_id
                }), t.getForm());
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getForm: function() {
        var t = this, a = s.getNetAddresss("plugin.diyform.api.diy-form.get-diy-form-by-id");
        a += "&form_id=" + this.data.form_id, s._getNetWork({
            url: a,
            success: function(a) {
                var e = a.data;
                if (1 == e.result) {
                    t.setData({
                        diyform: e.data
                    });
                    var i = t.data.diyform.fields, n = t.data.diydata, o = {};
                    for (var d in i) {
                        if (console.log(i[d].data_type), "diycheckbox" == t.data.types[i[d].data_type]) o = {
                            name: d,
                            data: i[d],
                            value: [],
                            type: t.data.types[i[d].data_type]
                        }; else if ("7" == i[d].data_type) {
                            var r = Date.parse(new Date()), l = new Date(r), u = l.getFullYear(), p = l.getMonth() + 1 < 10 ? "0" + (l.getMonth() + 1) : l.getMonth() + 1, c = l.getDate() < 10 ? "0" + l.getDate() : l.getDate();
                            console.log(u + "-" + p + "-" + c);
                            var g = u + "-" + p + "-" + c;
                            o = {
                                name: d,
                                data: i[d],
                                value: "",
                                type: t.data.types[i[d].data_type],
                                shoTime: s._isTextEmpty(i[d].default_time) ? g : i[d].default_time
                            };
                        } else if ("diyselect" == t.data.types[i[d].data_type]) {
                            for (var h = [], m = 0; m < i[d].tp_text.length; m++) h.push({
                                name: i[d].tp_text[m]
                            });
                            o = {
                                name: d,
                                data: i[d],
                                value: "",
                                type: t.data.types[i[d].data_type],
                                diysishow: !1,
                                sitem: h
                            };
                        } else o = "diycity" == t.data.types[i[d].data_type] ? {
                            name: d,
                            data: i[d],
                            value: "",
                            type: t.data.types[i[d].data_type],
                            showAdd: !1
                        } : "diydate" == t.data.types[i[d].data_type] ? {
                            name: d,
                            data: i[d],
                            value: "",
                            type: t.data.types[i[d].data_type],
                            timeShow: !1,
                            currentDate: new Date().getTime()
                        } : "diyimage" == t.data.types[i[d].data_type] ? {
                            name: d,
                            data: i[d],
                            imgUrls: [],
                            isPhoto: !1,
                            type: t.data.types[i[d].data_type]
                        } : {
                            name: d,
                            data: i[d],
                            value: "",
                            type: t.data.types[i[d].data_type]
                        };
                        n.push(o), t.setData({
                            diydata: n
                        });
                    }
                }
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    usernameinp: function(t) {
        var a = t.detail.value;
        this.setData({
            "applyModel.username": a
        });
    },
    passwordinp: function(t) {
        var a = t.detail;
        this.setData({
            "applyModel.password": a
        }), this.msgText = this.checkStrong(a), 3 == this.msgText ? this.setData({
            showtips: !1
        }) : this.setData({
            showtips: !0
        });
    },
    checkStrong: function(t) {
        var a = 0;
        return t.length < 1 ? a : (/\d/.test(t) && a++, /[a-z]/.test(t) && a++, /[A-Z]/.test(t) && a++, 
        1 == a ? 1 : 2 == a || t.length < 8 ? 2 : 3);
    },
    realnameinp: function(t) {
        var a = t.detail.value;
        this.setData({
            "applyModel.realname": a
        });
    },
    mobileinp: function(t) {
        var a = t.detail.value;
        this.setData({
            "applyModel.mobile": a
        });
    },
    productinp: function(t) {
        var a = t.detail.value;
        this.setData({
            "applyModel.product": a
        });
    },
    remarkinp: function(t) {
        var a = t.detail.value;
        this.setData({
            "applyModel.remark": a
        });
    },
    tpnameinp: function(t) {
        var e = t.detail.value, i = t.currentTarget.dataset.idex;
        this.setData(a({}, "diydata[" + i + "].value", e));
    },
    onRead_1: function(t) {
        var a = t.currentTarget.dataset.name;
        this.setData({
            setname: a
        });
        var e = this, i = s.getNetAddresss(this.data.uploadUrl);
        wx.chooseImage({
            count: 1,
            sizeType: [ "original", "compressed" ],
            sourceType: [ "album", "camera" ],
            success: function(t) {
                var a = t.tempFilePaths;
                console.log(a[0]), wx.compressImage({
                    src: a[0],
                    quality: 60,
                    success: function(t) {
                        var a = t.tempFilePath;
                        wx.uploadFile({
                            url: i,
                            filePath: a,
                            name: "file",
                            formData: {
                                attach: e.data.setname
                            },
                            success: function(t) {
                                var a = JSON.parse(t.data);
                                if (1 == a.result) {
                                    for (var i = e.data.diydata, s = 0; s < i.length; s++) i[s].name == a.data.attach && i[s].imgUrls.push(a.data.img_url);
                                    e.setData({
                                        diydata: i
                                    });
                                } else wx.showToast({
                                    icon: "none",
                                    title: a.msg,
                                    duration: 1500
                                });
                            }
                        });
                    },
                    fail: function(t) {},
                    complete: function(t) {}
                });
            }
        });
    },
    upIdCard: function(t) {
        var e = t.currentTarget.dataset.index, i = this, n = s.getNetAddresss("upload.uploadPic");
        wx.chooseImage({
            count: 1,
            sizeType: [ "original", "compressed" ],
            sourceType: [ "album", "camera" ],
            success: function(t) {
                var s = t.tempFilePaths[0];
                wx.showLoading({
                    title: "上传图片中"
                }), wx.uploadFile({
                    url: n,
                    filePath: s,
                    name: "file",
                    success: function(t) {
                        wx.hideLoading();
                        var s = JSON.parse(t.data);
                        if (1 != s.result) return wx.showToast({
                            icon: "none",
                            title: s.msg,
                            duration: 1500
                        }), !1;
                        var n = "imagefile" + e;
                        i.setData(a({}, n, s.data.img_url));
                    },
                    fail: function() {
                        wx.hideLoading();
                    }
                });
            }
        });
    },
    removeImg: function(t) {
        var a = t.currentTarget.dataset.indexc, e = t.currentTarget.dataset.index, i = this.data.diydata;
        i[e].imgUrls.splice(a, 1), this.setData({
            diydata: i
        });
    },
    diytextareainp: function(t) {
        var e = t.detail.value, i = t.currentTarget.dataset.idex;
        this.setData(a({}, "diydata[" + i + "].value", e));
    },
    checkboxinp: function(t) {
        var e = t.detail, i = t.currentTarget.dataset.idex;
        this.setData(a({}, "diydata[" + i + "].value", e));
    },
    diyselectBtn: function(t) {
        var e = t.currentTarget.dataset.idex;
        this.setData(a({}, "diydata[" + e + "].diysishow", !0));
    },
    sitemClose: function(t) {
        var e = t.currentTarget.dataset.idex;
        this.setData(a({}, "diydata[" + e + "].diysishow", !1));
    },
    sitemSelectBtn: function(t) {
        var e, i = t.currentTarget.dataset.idex;
        this.setData((a(e = {}, "diydata[" + i + "].value", t.detail.name), a(e, "diydata[" + i + "].diysishow", !1), 
        e));
    },
    raidinp: function(t) {
        var e = t.detail, i = t.currentTarget.dataset.idex;
        this.setData(a({}, "diydata[" + i + "].value", e));
    },
    showAddBtn: function(t) {
        var e = t.currentTarget.dataset.idex;
        this.setData(a({}, "diydata[" + e + "].showAdd", !0));
    },
    _closeDateLw: function(t) {
        var e = t.currentTarget.dataset.idex;
        this.setData(a({}, "diydata[" + e + "].showAdd", !1));
    },
    _initAddressInfo: function() {
        var t = this;
        wx.getStorage({
            key: "provinceData",
            success: function(a) {
                console.log("地址信息准备就绪"), t._getProvinceData();
            },
            fail: function(a) {
                console.log("省fail"), s._getNetWork({
                    url: s.getNetAddresss("member.member-address.address"),
                    success: function(a) {
                        var e = a.data, i = e.data.province, s = e.data.city, n = e.data.district;
                        wx.setStorage({
                            key: "provinceData",
                            data: i
                        }), wx.setStorage({
                            key: "cityData",
                            data: s
                        }), wx.setStorage({
                            key: "districtData",
                            data: n
                        }), t._initAddressInfo();
                    },
                    fail: function(t) {},
                    state: !0
                });
            }
        });
    },
    _getProvinceData: function() {
        var t = this;
        wx.getStorage({
            key: "provinceData",
            success: function(a) {
                console.log("省读取成功", a.data), t.setData({
                    provinceData: a.data
                }), t.setData({
                    "selectAddressData[0].name": a.data[t.data.pickerValue[0]].areaname,
                    "selectAddressData[0].id": a.data[t.data.pickerValue[0]].id,
                    "selectAddressData[0].index": t.data.pickerValue[0]
                }), t._getCityData();
            }
        });
    },
    _getCityData: function() {
        var t = this.data.selectAddressData[0];
        console.log("城市", "_data", t);
        var a = this;
        wx.getStorage({
            key: "cityData",
            success: function(e) {
                console.log("城市读取成功", e);
                for (var i = [], s = 0; s < e.data.length; s++) e.data[s].parentid == t.id && i.push(e.data[s]);
                console.log("城市数据筛选", i), a.setData({
                    cityData: i
                }), a.setData({
                    "selectAddressData[1].name": i[a.data.pickerValue[1]].areaname,
                    "selectAddressData[1].id": i[a.data.pickerValue[1]].id,
                    "selectAddressData[1].index": a.data.pickerValue[1]
                }), a._getDistrictData();
            }
        });
    },
    _getDistrictData: function() {
        var t = this.data.selectAddressData[1];
        console.log("地区", "_data", t), console.log(t);
        var a = this;
        wx.getStorage({
            key: "districtData",
            success: function(e) {
                console.log("地区读取成功");
                for (var i = [], s = 0; s < e.data.length; s++) e.data[s].parentid == t.id && i.push(e.data[s]);
                console.log("地区数据筛选", i), a.setData({
                    districtData: i
                }), console.log("districtData", i), a.setData({
                    "selectAddressData[2].name": i[a.data.pickerValue[2]].areaname,
                    "selectAddressData[2].id": i[a.data.pickerValue[2]].id,
                    "selectAddressData[2].index": a.data.pickerValue[2]
                }), console.log("over", a.data.selectAddressData);
            }
        });
    },
    bindChange: function(t) {
        var a = t.detail.value;
        this.data.pickerValue[0] != a[0] && (a[1] = 0, a[2] = 0), this.data.pickerValue[1] != a[1] && (a[2] = 0), 
        this.setData({
            "pickerValue[0]": a[0],
            "pickerValue[1]": a[1],
            "pickerValue[2]": a[2]
        }), this._initAddressInfo();
    },
    resultAdd: function(t) {
        var e, i = t.currentTarget.dataset.idex, s = this.data.selectAddressData, n = s[0].name + " " + s[1].name + " " + s[2].name;
        this.setData((a(e = {}, "diydata[" + i + "].value", n), a(e, "diydata[" + i + "].showAdd", !1), 
        e));
    },
    openPicker: function(t) {
        var e = t.currentTarget.dataset.idex;
        this.setData(a({}, "diydata[" + e + "].timeShow", !0));
    },
    _closeDateLw_1: function() {
        this.setData({
            showCity1: !1
        });
    },
    resultAdd_1: function() {
        var t = this.data.selectAddressData;
        this.setData({
            "applyModel.province_name": t[0].name,
            "applyModel.city_name": t[1].name,
            "applyModel.district_name": t[2].name,
            fullAddress: t[0].name + " " + t[1].name + " " + t[2].name,
            showCity1: !1,
            "applyModel.street_name": "",
            districtVal: []
        }), this._getStreet(t[2].id);
    },
    _getStreet: function(t) {
        var a = this, e = s.getNetAddresss("member.memberAddress.street");
        e += "&district_id=" + t, s._getNetWork({
            url: e,
            success: function(t) {
                var e = t.data;
                1 != e.result || s._isTextEmpty(e.data) ? a.setData({
                    isShowStreet: !1
                }) : !s._isTextEmpty(e.data) && e.data.length > 0 ? a.setData({
                    districtVal: e.data,
                    isShowStreet: !0
                }) : a.setData({
                    isShowStreet: !1
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    streetChoose: function() {
        s._isTextEmpty(this.data.fullAddress) ? wx.showToast({
            icon: "none",
            title: "请先选择所在地区",
            duration: 1500
        }) : this.setData({
            streetShow: !0,
            opren: !1
        });
    },
    streetConfirm: function(t) {
        var a = t.target.dataset.strname;
        this.setData({
            "applyModel.street_name": a,
            streetShow: !1
        });
    },
    streetClose: function(t) {
        this.setData({
            streetShow: !1,
            opren: !0
        });
    },
    setApplyData: function() {
        if (!s._isTextEmpty(this.data.applyModel.username) || this.data.apply_switch) if (!s._isTextEmpty(this.data.applyModel.password) || this.data.apply_switch) if (3 == this.data.msgText || 1 != this.data.pass_safe) if (s._isTextEmpty(this.data.applyModel.realname)) wx.showToast({
            icon: "none",
            title: "请填写真实姓名",
            duration: 1500
        }); else if (s._isTextEmpty(this.data.applyModel.mobile)) wx.showToast({
            icon: "none",
            title: "请填写手机号码",
            duration: 1500
        }); else if (s._isMoblie(this.data.applyModel.mobile)) wx.showToast({
            icon: "none",
            title: "请输入正确的手机号",
            duration: 1500
        }); else if (s._isTextEmpty(this.data.applyModel.product)) wx.showToast({
            icon: "none",
            title: "请填写产品类型",
            duration: 1500
        }); else if (s._isTextEmpty(this.data.applyModel.group_id) && "1" === this.data.is_open_group) wx.showToast({
            icon: "none",
            title: "请选择分组",
            duration: 1500
        }); else if (s._isTextEmpty(this.data.applyModel.category_id) && "1" === this.data.is_open_category) wx.showToast({
            icon: "none",
            title: "请选择行业",
            duration: 1500
        }); else if (s._isTextEmpty(this.data.applyModel.aptitude) && 1 === this.data.up_aptitude) wx.showToast({
            icon: "none",
            title: "上传营业执照",
            duration: 1500
        }); else if (1 === this.data.is_identity && s._isTextEmpty(this.data.imagefile1) && s._isTextEmpty(this.data.imagefile2)) wx.showToast({
            icon: "none",
            title: "上传身份证",
            duration: 1500
        }); else if (this.data.agreement) {
            this.data.applyModel.identity[0] = this.data.imagefile1, this.data.applyModel.identity[1] = this.data.imagefile2;
            var t = this, a = s.getNetAddresss("plugin.supplier.supplier.controllers.apply.supplier-apply.apply");
            a += "&apply=" + JSON.stringify(this.data.applyModel), s._getNetWork({
                url: a,
                success: function(a) {
                    var e = a.data;
                    1 == e.result ? t.setData({
                        supplier_status: e.data.status
                    }) : wx.showModal({
                        content: e.msg,
                        showCancel: !1
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        } else wx.showToast({
            icon: "none",
            title: "请先阅读协议",
            duration: 1500
        }); else wx.showToast({
            icon: "none",
            title: "请正确填写密码",
            duration: 1500
        }); else wx.showToast({
            icon: "none",
            title: "请填写密码",
            duration: 1500
        }); else wx.showToast({
            icon: "none",
            title: "请填写账号",
            duration: 1500
        });
    },
    submit: function() {
        this.validation(), this.data.isValidation && (this.data.agreement ? this.submitForm() : wx.showToast({
            icon: "none",
            title: "请先阅读协议",
            duration: 1500
        }));
    },
    validation: function() {
        var t = this;
        this.setData({
            isValidation: !0
        }), this.data.diydata.forEach(function(a) {
            1 != a.data.tp_must || a.value || "diyimage" == a.type || (wx.showToast({
                icon: "none",
                title: a.data.tp_name + "必须填写哦",
                duration: 1500
            }), t.setData({
                isValidation: !1
            })), 1 == a.data.tp_must && "diyimage" == a.type && a.imgUrls.length < a.data.tp_max && (wx.showToast({
                icon: "none",
                title: a.data.tp_name + "必须上传" + a.data.tp_max + "张",
                duration: 1500
            }), t.setData({
                isValidation: !1
            })), "diycheckbox" == a.type && 0 == a.value.length && (wx.showToast({
                icon: "none",
                title: a.data.tp_name + "必须选择哦",
                duration: 1500
            }), t.setData({
                isValidation: !1
            }));
        });
    },
    submitForm: function() {
        var t = this, a = [], e = {};
        this.data.diydata.forEach(function(t) {
            "diyimage" == t.type ? e[t.name] = t.imgUrls : e[t.name] = t.value;
        }), a.push(e);
        var i = {
            form_id: this.data.form_id,
            form_data: a
        }, n = s.getNetAddresss("plugin.diyform.api.diy-form.save-diy-form-data");
        s._postNetWork({
            url: n,
            showToastIn: !1,
            data: i,
            success: function(a) {
                var e = a.data;
                1 == e.result ? t.submitApplyByForm(e.data.form_data_id) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {}
        });
    },
    submitApplyByForm: function(t) {
        var a = s.getNetAddresss("plugin.supplier.supplier.controllers.apply.supplier-apply.apply");
        a += "&form_data_id=" + t, s._getNetWork({
            url: a,
            success: function(t) {
                var a = t.data;
                1 == a.result ? wx.showToast({
                    title: a.msg,
                    icon: "none",
                    duration: 1500,
                    success: function() {
                        setTimeout(function() {
                            wx.navigateBack({
                                delta: 1
                            });
                        }, 1500);
                    }
                }) : wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    showCity1btn: function() {
        this.setData({
            showCity1: !0
        });
    },
    goHome: function() {
        wx.reLaunch({
            url: "/packageG/index/index"
        });
    },
    previewImage: function(t) {
        wx.previewImage({
            current: t.target.dataset.src,
            urls: t.target.dataset.srcList
        });
    },
    onShareTimeline: function() {},
    onShareAppMessage: function() {}
});